<?php

require_once("../config/dbconn.php");require_once("../config/usercls.php");
require_once("pwd1cls.php");

$sqlhy="select * from {$db_prefix}users where id='".$_SESSION['sys_userid']."'";
$rshy=$db->get_one($sqlhy);
if($act=='edit' && $rshy['rank']<3){
   
	//插入到数据库
	unset($dataArray);
    $dataArray['rank']=trim($rank);
        //判断情况
    if($rshy['rank']==1 && $dataArray['rank']-$rshy['rank']==1){
        $dataArray['price']=$rshy['price']-$glo_regprice_2+$glo_regprice_1;
        $dataArray['gcprice']=$rshy['gcprice']+$glo_regprice_2-$glo_regprice_1;
        if($dataArray['price']<0){
            	echo "<script>alert('报单币不足');location.href='info_up.php';</script>";exit();
        }
    }
     if($rshy['rank']==1 && $dataArray['rank']-$rshy['rank']==2){
         $dataArray['price']=$rshy['price']-$glo_regprice_3+$glo_regprice_1;
         $dataArray['gcprice']=$rshy['gcprice']+$glo_regprice_3-$glo_regprice_1;
        if($dataArray['price']<0){
            	echo "<script>alert('报单币不足');location.href='info_up.php';</script>";exit();
        }
     }
     if($rshy['rank']==2 && $dataArray['rank']-$rshy['rank']==1){
         $dataArray['price']=$rshy['price']-$glo_regprice_3+$glo_regprice_2;
         $dataArray['gcprice']=$rshy['gcprice']+$glo_regprice_3-$glo_regprice_2;
        if($dataArray['price']<0){
            	echo "<script>alert('报单币不足');location.href='info_up.php';</script>";exit();
        }
    }
    
    $db->update("{$db_prefix}users",$dataArray,"id='".$_SESSION['sys_userid']."'");
    

	//财务记录
/*	$e_userid=$_SESSION['sys_userid'];$e_price=-$glo_bdneed;$e_type=1;$e_ptype=1;$e_addtime=$curtime;$e_memo="注册会员{$username}，报单币";
hyepricejl($e_userid,$e_price,$e_type,$e_ptype,$e_addtime,$e_memo);	*/
	//更新成功
	
	echo "<script>alert('会员升级成功');location.href='info_up.php';</script>";exit();
}else if($rshy['rank']>=3){
    	echo "<script>alert('会员已是最高级，无法升级！');</script>";exit();
}


?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="images/bootstrap.css" rel="stylesheet" type="text/css" />
<style type="text/css">

body {margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px;}
.content{ border-left:2px solid; border-bottom:2px solid; border-right:2px solid; border-color:#CCC; min-height:400px; width:98%; margin:0 auto; }
.title{ width:100%; height:35px;  background:url(images/title_bg.png); padding:2px;}
.title a{ }
.hhdj{ width:500px; margin:0 auto; padding:5px; }
.hhxj{ width:500px; margin:0 auto; padding:5px; }
.hhtj{ width:500px; margin:0 auto; padding:5px; }
</style>

<link href="images/skin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="content">
	<div class="title">
    	<a>会员升级</a>
    </div>
    <form class="form-horizontal" align="middle" name="form1" id="form1" action="?act=edit" method="post" >
		<div class="hhdj">
        	会员等级：<?=$hyrankary[$rshy['rank']]?><br/>
        </div>
        <div class="hhxj">
        	<select name="rank" id="rank">
                <option value="<?=$rshy['rank']+1?>"><?=$hyrankary[$rshy['rank']+1]?></option>
                <option value="<?=$rshy['rank']+2?>"><?=$hyrankary[$rshy['rank']+2]?></option>
        	</select>
        </div>
        <div class="hhtj">
        	<input class="btn btn-primary btn-lg" type="submit" value="会员升级" name="B1" id="B1"/>
        </div>
        
    </form>
</div>
</body>
</html>
